﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Convertor.Interface;
using Wpf.CommonTools.SystemExtension;

namespace Convertor.Plugin.SelectDirectory
{
    [Serializable]
    public class ConfigContent : IConfigContent, ISerializable, ICloneable, INotifyPropertyChanged
    {
        private string saveFilePath;

        public string SaveFilePath
        {
            get { return saveFilePath; }
            set { saveFilePath = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("ToolTip")); } }
        }

        public ConfigContent()
        {
        }
        
        public override string ToString()
        {
            return ToolTip;
        }

        #region IToolTip 成员

        public string ToolTip
        {
            get
            {
                return string.Format(UILanguage.TryFindResource("Plugin_SelectDirectory_Info"),
                    this.saveFilePath);
            }
        }

        #endregion

        #region ISerializable 成员

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("SaveFilePath", SaveFilePath, typeof(string));
        }

        public ConfigContent(SerializationInfo info, StreamingContext context)
        {
            saveFilePath = (string)info.GetValue("SaveFilePath", typeof(string));
        }

        #endregion

        #region ICloneable 成员

        public object Clone()
        {
            ConfigContent a = new ConfigContent()
            {
                SaveFilePath = this.SaveFilePath
            };
            return a;
        }

        #endregion


        #region INotifyPropertyChanged 成员

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
